<?php
/**
 * index.php
 * @author 瀚海浪亭
 * @email  1171672036@qq.com
 * @date   2021/4/19
 */

use think\facade\Route;

Route::group('',function () {

    Route::group('v1', function () {
        //测试公开接口签名验证
        Route::any('index', 'index/index');
        //资源路由示例
        //请求类型	生成路由规则	    对应操作方法（默认）
        //GET	    user	        index
        //GET	    user/create	    create
        //POST	    user	        save
        //GET	    user/:id	    read
        //GET	    user/:id/edit	edit
        //PUT	    user/:id	    update
        //DELETE	user/:id	    delete

        //测试用户授权接口
        Route::resource('user', 'User');

        Route::post('reg', 'User/reg');
        Route::post('login', 'User/login');
    })->prefix('v1.')->allowCrossDomain();

    Route::group('v2', function () {
        Route::post('index', 'index/index');
        //...
    })->prefix('v2.');

})->allowCrossDomain();

//请求示例
//http://localhost:81/api/v1/user  对应 api/v1/UserController/index